﻿using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

namespace Studio
{
	// Token: 0x020004CD RID: 1229
	public class ItemList : MonoBehaviour
	{
		// Token: 0x06001F4C RID: 8012 RVA: 0x000C2D78 File Offset: 0x000C0F78
		public void InitList(int _group)
		{
			if (this.group == _group)
			{
				return;
			}
			int childCount = this.transformRoot.childCount;
			for (int j = 0; j < childCount; j++)
			{
				UnityEngine.Object.Destroy(this.transformRoot.GetChild(j).gameObject);
			}
			this.scrollRect.verticalNormalizedPosition = 1f;
			foreach (KeyValuePair<int, Info.ItemLoadInfo> keyValuePair in from i in Singleton<Info>.Instance.dicItemLoadInfo
			where i.Value.@group == _group
			select i)
			{
				GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.objectNode);
				gameObject.transform.SetParent(this.transformRoot, false);
				StudioNode component = gameObject.GetComponent<StudioNode>();
				component.active = true;
				int no = keyValuePair.Key;
				component.addOnClick = delegate()
				{
					this.OnSelect(no);
				};
				component.text = keyValuePair.Value.name;
				component.textColor = ((!(keyValuePair.Value.isColor & keyValuePair.Value.isColor2)) ? ((!(keyValuePair.Value.isColor | keyValuePair.Value.isColor2)) ? Color.white : Color.red) : Color.cyan);
				if (keyValuePair.Value.isColor | keyValuePair.Value.isColor2)
				{
					Shadow shadow = component.textUI.gameObject.AddComponent<Shadow>();
					shadow.effectColor = Color.black;
				}
			}
			if (!base.gameObject.activeSelf)
			{
				base.gameObject.SetActive(true);
			}
			this.group = _group;
		}

		// Token: 0x06001F4D RID: 8013 RVA: 0x000C2F90 File Offset: 0x000C1190
		private void OnSelect(int _no)
		{
			Singleton<Studio>.Instance.AddItem(_no);
		}

		// Token: 0x06001F4E RID: 8014 RVA: 0x000C2FA0 File Offset: 0x000C11A0
		private void Awake()
		{
			this.group = -1;
		}

		// Token: 0x04002119 RID: 8473
		[SerializeField]
		private Transform transformRoot;

		// Token: 0x0400211A RID: 8474
		[SerializeField]
		private GameObject objectNode;

		// Token: 0x0400211B RID: 8475
		[SerializeField]
		private ScrollRect scrollRect;

		// Token: 0x0400211C RID: 8476
		private int group = -1;
	}
}
